//
//  WebviewForNews.m
//  MY Project For Sport
//
//  Created by dllo on 16/1/27.
//  Copyright © 2016年 dilo. All rights reserved.
//

#import "WebviewForNews.h"

#define WEIGHTT [UIScreen mainScreen].bounds.size.width / 375
#define HEIGHTT [UIScreen mainScreen].bounds.size.height / 667


@interface WebviewForNews ()

@property (nonatomic, retain) UIWebView *webView;
@property (nonatomic, retain) UIView *viewForNail;
@property (nonatomic, retain) UIButton *button;
@end

@implementation WebviewForNews

- (void)dealloc {

    [_webView release];
    [_url release];
    [_viewForNail release];
    [_button release];
    [super dealloc];

}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self createWebView];
    
    // 隐藏navigationController
    
   // self.navigationController.navigationBarHidden = NO;
}

- (void)createWebView {

//    //创建一个 view覆盖顶部的 navigationcontroller
//    self.viewForNail = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 44)];
//   self.viewForNail.backgroundColor = [UIColor whiteColor];
//    [self.navigationController.navigationBar addSubview:self.viewForNail];
//    [_viewForNail release];
//    
//    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40 * WEIGHTT, 40 * HEIGHTT)];
//    [self.viewForNail addSubview:label];
//    [label release];
//    label.textColor = [UIColor redColor];
//    label.center = self.viewForNail.center;
//    label.text = @"网页";
//    
//
//    // 创建返回上一个界面的 button
//    self.button = [UIButton buttonWithType:UIButtonTypeSystem];
//    self.button.frame = CGRectMake(5 * WEIGHTT, 5 * HEIGHTT, 30 * WEIGHTT, 30 * HEIGHTT);
//    [self.navigationController.navigationBar addSubview:self.button];
//    [self.button addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];
//    
    
    // webView
    self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    
    [self.view addSubview:self.webView];
    [_webView release];
    
    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:self.url]];
    
    [self.webView loadRequest:request];
    [request release];

}

- (void)buttonAction {

    [self.navigationController popViewControllerAnimated:YES];
    //当点击 button 的时候让顶部的 view 和 button 隐藏同时进入上一个 vc
    self.viewForNail.hidden = YES;
    self.button.hidden = YES;

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
